import pygame
import sys
import time

#Iniciar pygame
pygame.init()

# Configurar la ventana
ancho = 1024
alto = 700
ventana = pygame.display.set_mode((ancho, alto))
pygame.display.set_caption("MARS INVASION")

#Defino la imagen de fondo
fondo = pygame.image.load("img/MARCIANOS.jpg")
x,y = 0,0
ventana.blit(fondo,[x,y])
pygame.display.flip()
#Defino al personaje
personaje = pygame.image.load("img/imagen.png")
x2,y2 = 450,600
ventana.blit(personaje,[x2,y2])
pygame.display.flip()
#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x3 = 500
y3 = 100
ventana.blit(marciano,[x3,y3])
pygame.display.flip()
#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x4 = 600
y4 = 100
ventana.blit(marciano,[x4,y4])
pygame.display.flip()
#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x5 = 700
y5 = 100
ventana.blit(marciano,[x5,y5])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x6 = 800
y6 = 100
ventana.blit(marciano,[x6,y6])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x7 = 400
y7 = 100
ventana.blit(marciano,[x7,y7])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x8 = 300
y8 = 100
ventana.blit(marciano,[x8,y8])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x9 = 200
y9 = 100
ventana.blit(marciano,[x9,y9])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x10 = 200
y10 = 200
ventana.blit(marciano,[x10,y10])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x11 = 200
y11 = 200
ventana.blit(marciano,[x11,y11])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x12 = 300
y12 = 200
ventana.blit(marciano,[x12,y12])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x13 = 400
y13 = 200
ventana.blit(marciano,[x13,y13])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x14 = 800
y14 = 200
ventana.blit(marciano,[x14,y14])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x15 = 700
y15 = 200
ventana.blit(marciano,[x15,y15])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x16 = 600
y16 = 200
ventana.blit(marciano,[x16,y16])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x17 = 500
y17 = 200
ventana.blit(marciano,[x17,y17])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x18 = 200
y18 = 300
ventana.blit(marciano,[x18,y18])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x19 = 300
y19 = 300
ventana.blit(marciano,[x19,y19])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x20 = 400
y20 = 300
ventana.blit(marciano,[x20,y20])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x21 = 500
y21 = 300
ventana.blit(marciano,[x21,y21])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x22 = 600
y22 = 300
ventana.blit(marciano,[x22,y22])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x23 = 700
y23 = 300
ventana.blit(marciano,[x23,y23])
pygame.display.flip()

#Defino marciano
marciano = pygame.image.load("img/marciano1.jpg")
x24 = 800
y24 = 300
ventana.blit(marciano,[x24,y24])
pygame.display.flip()

    
#Bucle de eventos
while True:
	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			pygame.quit()
			sys.exit()
		if event.type == pygame.KEYDOWN:
			if event.key == pygame.K_RIGHT:
				ventana.blit(fondo,[x,y])
				ventana.blit(marciano,[x3,y3])
				ventana.blit(marciano,[x4,y4])
				ventana.blit(marciano,[x5,y5])
				ventana.blit(marciano,[x6,y6])
				ventana.blit(marciano,[x7,y7])
				ventana.blit(marciano,[x8,y8])
				ventana.blit(marciano,[x9,y9])
				ventana.blit(marciano,[x10,y10])
				ventana.blit(marciano,[x11,y11])
				ventana.blit(marciano,[x12,y12])
				ventana.blit(marciano,[x13,y13])
				ventana.blit(marciano,[x14,y14])
				ventana.blit(marciano,[x15,y15])
				ventana.blit(marciano,[x16,y16])
				ventana.blit(marciano,[x17,y17])
				ventana.blit(marciano,[x18,y18])
				ventana.blit(marciano,[x19,y19])
				ventana.blit(marciano,[x20,y20])
				ventana.blit(marciano,[x21,y21])
				ventana.blit(marciano,[x22,y22])
				ventana.blit(marciano,[x23,y23])
				ventana.blit(marciano,[x24,y24])
				x2 = x2 + 4
				ventana.blit(personaje,[x2,y2])
				pygame.display.flip() 
			if event.key == pygame.K_LEFT:
				ventana.blit(fondo,[x,y])
				ventana.blit(marciano,[x3,y3])
				ventana.blit(marciano,[x4,y4])
				ventana.blit(marciano,[x5,y5])
				ventana.blit(marciano,[x6,y6])
				ventana.blit(marciano,[x7,y7])
				ventana.blit(marciano,[x8,y8])
				ventana.blit(marciano,[x9,y9])
				ventana.blit(marciano,[x10,y10])
				ventana.blit(marciano,[x11,y11])
				ventana.blit(marciano,[x12,y12])
				ventana.blit(marciano,[x13,y13])
				ventana.blit(marciano,[x14,y14])
				ventana.blit(marciano,[x15,y15])
				ventana.blit(marciano,[x16,y16])
				ventana.blit(marciano,[x17,y17])
				ventana.blit(marciano,[x18,y18])
				ventana.blit(marciano,[x19,y19])
				ventana.blit(marciano,[x20,y20])
				ventana.blit(marciano,[x21,y21])
				ventana.blit(marciano,[x22,y22])
				ventana.blit(marciano,[x23,y23])
				ventana.blit(marciano,[x24,y24])
				x2 = x2 - 4
				ventana.blit(personaje,[x2,y2])
				pygame.display.flip()
			if event.key == pygame.K_UP:
				ventana.blit(fondo,[x,y])
				ventana.blit(marciano,[x3,y3])
				ventana.blit(marciano,[x4,y4])
				ventana.blit(marciano,[x5,y5])
				ventana.blit(marciano,[x6,y6])
				ventana.blit(marciano,[x7,y7])
				ventana.blit(marciano,[x8,y8])
				ventana.blit(marciano,[x9,y9])
				ventana.blit(marciano,[x10,y10])
				ventana.blit(marciano,[x11,y11])
				ventana.blit(marciano,[x12,y12])
				ventana.blit(marciano,[x13,y13])
				ventana.blit(marciano,[x14,y14])
				ventana.blit(marciano,[x15,y15])
				ventana.blit(marciano,[x16,y16])
				ventana.blit(marciano,[x17,y17])
				ventana.blit(marciano,[x18,y18])
				ventana.blit(marciano,[x19,y19])
				ventana.blit(marciano,[x20,y20])
				ventana.blit(marciano,[x21,y21])
				ventana.blit(marciano,[x22,y22])
				ventana.blit(marciano,[x23,y23])
				ventana.blit(marciano,[x24,y24])
				y2 = y2 - 4
				ventana.blit(personaje,[x2,y2])
				pygame.display.flip()
			if event.key == pygame.K_DOWN:
				ventana.blit(fondo,[x,y])
				ventana.blit(marciano,[x3,y3])
				ventana.blit(marciano,[x4,y4])
				ventana.blit(marciano,[x5,y5])
				ventana.blit(marciano,[x6,y6])
				ventana.blit(marciano,[x7,y7])
				ventana.blit(marciano,[x8,y8])
				ventana.blit(marciano,[x9,y9])
				ventana.blit(marciano,[x10,y10])
				ventana.blit(marciano,[x11,y11])
				ventana.blit(marciano,[x12,y12])
				ventana.blit(marciano,[x13,y13])
				ventana.blit(marciano,[x14,y14])
				ventana.blit(marciano,[x15,y15])
				ventana.blit(marciano,[x16,y16])
				ventana.blit(marciano,[x17,y17])
				ventana.blit(marciano,[x18,y18])
				ventana.blit(marciano,[x19,y19])
				ventana.blit(marciano,[x20,y20])
				ventana.blit(marciano,[x21,y21])
				ventana.blit(marciano,[x22,y22])
				ventana.blit(marciano,[x23,y23])
				ventana.blit(marciano,[x24,y24])
				y2 = y2 + 4
				ventana.blit(personaje,[x2,y2])
				pygame.display.flip()
